# coding: utf-8
import os
import sys
from datetime import datetime

from PySide6.QtCore import QUrl
from PySide6.QtGui import QDesktopServices, QColor
from qfluentwidgets import isDarkTheme


def isWin11():
    return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000


def openUrl(url: str):
    if not url.startswith("http"):
        if not os.path.exists(url):
            return False

        QDesktopServices.openUrl(QUrl.fromLocalFile(url))
    else:
        QDesktopServices.openUrl(QUrl(url))

    return True


def getThemeColor(alpha: int = 150) -> QColor:
    c = 0 if isDarkTheme() else 255
    return QColor(c, c, c, alpha)


def getGMTTime():
    gmt_format = '%a %b %d %Y %H:%M:%S GMT 0800 (中国标准时间)'
    return datetime.now().strftime(gmt_format)
